
if exists (select * from dbo.sysobjects where name='sp_CapNhatNhanVien')
begin
	drop proc sp_CapNhatNhanVien
end
go
create proc sp_CapNhatNhanVien
	@MANV	varchar(10),
	@HONV	varchar(10),
	@TENLOT	varchar(10),
	@TENNV	varchar(10),
	@NGSINH	datetime,
	@DCHI	varchar(100),
	@PHAI	varchar(3),
	@LUONG	numeric,
	@MA_NQL	varchar(10),
	@PHG		int,

@status int output
as
begin
	if exists (select * from NHANVIEN where MANV =@MANV)
	begin
		set @status=1
		print 'da ton tai'
		update	NHANVIEN set HONV=@HONV , TENLOT=@TENLOT,TENNV=@TENNV,NGSINH=@NGSINH,DCHI=@DCHI,PHAI=@PHAI,LUONG=@LUONG,MA_NQL=@MA_NQL,PHG=@PHG 
		where MANV=@MANV	
	end 
	else
	begin
		set @status=0
		print 'chua ton tai'
		insert into NHANVIEN values (@MANV, @HONV , @TENLOT,@TENNV,@NGSINH,@DCHI,@PHAI,@LUONG,@MA_NQL,@PHG)
	end

end